package com.br.aiops.storage.counter;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;

public interface CounterLadderValueRepository extends JpaRepository<CounterLadderValueDTO,Integer> {

    /**
     * 查询阶梯的value数据
     * @param counterKey counterKey
     * @return
     */
    @Query(nativeQuery = true, value = "select * from log_alert_counter_ladder_value where counter_key = ?1")
    CounterLadderValueDTO findLadderValue(String counterKey);

    CounterLadderValueDTO findByCounterKey(String counterKey);

    /**
     * 根据key删除
     * @param key
     */
    @Query(nativeQuery = true, value = "delete from log_alert_counter_ladder_value where counter_key = ?1")
    @Modifying
    @Transactional
    void deleteByKey(String key);
}
